package com.springboot.system.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.springboot.system.domain.auth.Job;
import com.springboot.system.service.JobService;
import com.springboot.core.log.annotation.Log;
import com.springboot.core.security.permission.CheckPermission;
import com.springboot.core.web.mvc.BaseRest;
import com.springboot.core.web.mvc.R;

/**
 * 岗位接口
 * 
 * @ClassName: JobRest
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author 252956
 * @date 2019年11月21日 上午11:21:51
 *
 */
@RestController
@RequestMapping(value = "/rest/job")
public class JobRest extends BaseRest {
	@Autowired
	private JobService jobService;

	@RequestMapping(value = "page", method = RequestMethod.POST)
	public R page(@RequestBody Job job) {
		return R.ok(jobService.page(job));

	}

	@RequestMapping(value = "all")
	public R all() {
		return R.ok(jobService.selectAll());

	}

	@Log(value = "添加岗位")
	@CheckPermission("job:add")
	@RequestMapping(value = "add", method = RequestMethod.POST)
	public R add(@RequestBody Job job) {
		jobService.add(job);
		return R.ok();
	}

	@Log(value = "修改岗位")
	@CheckPermission("job:edit")
	@RequestMapping(value = "update", method = RequestMethod.POST)
	public R update(@RequestBody Job job) {
		jobService.update(job);
		return R.ok();
	}

	@Log(value = "删除岗位")
	@CheckPermission("job:del")
	@RequestMapping(value = "delete")
	public R delete(@RequestParam("id") Integer id) {
		jobService.delete(id);
		return R.ok();
	}

	@Log(value = "更新岗位状态")
	@RequestMapping(value = "updateStatus", method = RequestMethod.POST)
	public R updateStatus(@RequestBody Job job) {
		jobService.updateStatus(job);
		return R.ok();

	}
}
